home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 039a / uw201.zip / UW.H < prev    next >
Text File  |  1991-10-07  |  11KB  |  291 lines

  1. /****************************************************************************/
  2. /*                                                                                                                                                    */
  3. /* UW.H                                                                                                                                            */
  4. /*                                                                                                                                                    */
  5. /* This is the main header for uWin, containing all the defines and                    */
  6. /* typedefs for the program.                                                                                                */
  7. /*                                                                                                                    Kevin Huck            */
  8. /*                                                                                                                    Boyd Gafford        */
  9. /*                                                                                                                                                    */
  10. /****************************************************************************/
  11. #include <dos.h>                            /* for the REGS definition used for mouse int    */
  12. #include <stdlib.h>
  13. #include <time.h>
  14. #include <conio.h>
  15. #include <string.h>
  16. #ifdef M_I86                                /* Microsofts are malloc.h and memory.h        */
  17.     #include <malloc.h>
  18.     #include <memory.h>
  19.     #include <sys\types.h>
  20.     #pragma pack(1)
  21. #else                                                /* Borlands are alloc.h and mem.h              */
  22.     #include <alloc.h>
  23.     #include <mem.h>
  24. #endif
  25.  
  26. #ifdef M_I86
  27. #include <stddef.h>
  28. #define setmem(p,c,v)                memset((p),(v),(c))
  29. #define movmem(s,d,c)                memmove((d),(s),(c))
  30. #define random(x)               (rand() % (x))
  31. #define bioskey(c)                    _bios_keybrd(c)
  32. #define biosprint(s, d, p)    _bios_printer(s, p, d)
  33. #define getvect(i)          _dos_getvect(i)
  34. #define setvect(i,hdlr)     _dos_setvect(i,hdlr)
  35. #define enable              _enable
  36. #define disable             _disable
  37. #define setcolor            _setcolor
  38. #define moveto              _moveto
  39. #define lineto              _lineto
  40. struct  REGPACK {
  41.     unsigned    r_ax, r_bx, r_cx, r_dx;
  42.     unsigned    r_bp, r_si, r_di, r_ds, r_es, r_flags;
  43. };
  44. enum COLORS {
  45.     BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN,
  46.     LIGHTGRAY, DARKGRAY, LIGHTBLUE, LIGHTGREEN,
  47.     LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE
  48. };
  49. #define BW80 2
  50. #define C80  3
  51. #define MONO 7
  52. #endif
  53.  
  54. #define HEAD_ROOM        0x8000L        /* 32K memory head room space for allocation    */
  55.  
  56. /*------------------------ rectangle operation defines ---------------------*/
  57. #define     NO_OVERLAP            0
  58. #define        OVERLAP                    1
  59. #define        FIRST_ENCLOSED    2
  60. #define        SECOND_ENCLOSED    3
  61.  
  62. /*---------------------------- general defines -----------------------------*/
  63. #define   ON        1
  64. #define   OFF       0
  65. #define   UP        0
  66. #define   DOWN      1
  67. #define   LEFT      2
  68. #define   RIGHT     3
  69.  
  70. /*------------------------------ menuing defines ---------------------------*/
  71. #define     M_HORIZONTAL            0
  72. #define     M_VERTICAL                1
  73. #define     M_MAX_ENTRIES            20
  74. #define        M_GET_EVENT                0
  75. #define        M_PROC_EVENT            1
  76.  
  77.  
  78. /*---------------------------- mouse defines -------------------------------*/
  79. #define        TDELAY (clock_t) 4    /* clock ticks to check for multiple clicks        */
  80. #define        LB                0                    /* m_event->flag is 4 for left button                 */
  81. #define        MB                2                    /* m_event->flag is 64 for middle button            */
  82. #define        RB                1                    /* m_event->flag is 16 for right button                */
  83.  
  84. /*---------------------------- window defines ------------------------------*/
  85. #define   NO_BDR    0
  86. #define   SGL_BDR   1
  87. #define   DBL_BDR   2
  88. #define   SLD_BDR   3
  89. #define        DUAL_BDR    4
  90.  
  91. #define   CENTERED   -1
  92. #define   LEFT_JUST  -2
  93. #define   RIGHT_JUST -3
  94.  
  95. #define     ALPHA           'A'
  96. #define     DIGITS       'D'
  97. #define     C_LINE            0
  98. #define     C_SBLOCK    1
  99. #define     C_FBLOCK    2
  100.  
  101. #define   IN             0
  102. #define   OUT              1
  103. #define   BUFF             0
  104. #define   SAVE            1
  105.  
  106. #define        WN_POPUP    1
  107. #define        WN_NORMAL    0
  108.  
  109. #define   DELETE    1
  110. #define   INSERT    0
  111.  
  112. #define   STRIP_ON  1
  113. #define   STRIP_OFF 0
  114.  
  115. /*----------------------- printer support defines --------------------------*/
  116. #define PRT_BLOCK 2048
  117. #define MAX_PRINTERS 4
  118.  
  119. #define BLOCK_SIZE 512
  120.  
  121. #define READ  0
  122. #define WRITE 1
  123.  
  124. /*------------------------- flags for wn_gets_ll ---------------------------*/
  125. #define G_STRIP       0x0001
  126. #define G_STRIP_END   0x0002
  127. #define G_UP_FST_CHAR 0x0004
  128. #define G_ARROW       0x0008
  129. #define G_VALIDATE    0x0010
  130.  
  131. /*-------------------------- base level typedefs ---------------------------*/
  132. typedef unsigned char uchar;
  133. typedef unsigned int  uint;
  134. typedef unsigned long ulong;
  135.  
  136. /*---------------------------- mouse structures ----------------------------*/
  137. typedef struct reset_struct
  138. {
  139.     int exists;
  140.     int n_buttons;
  141. } M_RESET;
  142.  
  143. typedef struct loc_struct
  144. {
  145.     int button_status;
  146.     int count;
  147.     int col;
  148.     int row;
  149. } M_LOC;
  150.  
  151. typedef struct move_struct
  152. {
  153.     int h_count;
  154.     int v_count;
  155. } M_MOVE;
  156.  
  157. typedef struct event_struct
  158. {
  159.     char        is_mouse;
  160.     int            key;
  161.     int            mod;
  162.     int            m_x, m_y;
  163.     char        m_count, m_button;
  164. } EVENT;
  165.  
  166. /*---------------------------- rectangle structure -------------------------*/
  167. typedef struct rect_struct
  168. {
  169.     int x_min, x_max, y_min, y_max;                    /* rectangle coordinates                     */
  170. } RECT;
  171.  
  172.  
  173. /*--------------------------- window structure -----------------------------*/
  174. typedef struct w_struct
  175. {
  176.     struct w_struct    *next;                                    /* next window in linked list            */
  177.     struct w_struct    *previous;                            /* previous window in list                */
  178.     RECT                        pane;                   /* the window rectangle           */
  179.     RECT                        old_pane;               /* for full size toggle           */
  180.     int                            rows;                                        /* save buffer rows and columns        */
  181.     int                            cols;
  182.     int                         csr_x;                  /* the "soft" cursor location     */
  183.     int                         csr_y;
  184.     int                         att;                    /* the window's attribute         */
  185.     int                         bdr_att;                /* the window's border attribute  */
  186.     int                         bdr_style;              /* the border style               */
  187.     int                         name_loc;                                /* CENTERED, LEFTJUST, RIGHTJUST    */
  188.     char                        *name;                  /* pointer to window name         */
  189.     uchar                        *save;                                    /* pointer to save buffer area        */
  190.     uchar                        *buff;                                    /* pointer to write buffer area        */
  191.     uchar                        *mask;                                    /* pointer to window buffer mask    */
  192.  
  193.     uchar           *tabs;                                    /* tabs stops                     */
  194.     int                            reg_s, reg_e;                        /* scroll region start and end        */
  195.  
  196.     unsigned                w_wrap            : 1;                /* word wrap on/off                                */
  197.     unsigned                hidden            : 1;        /* 1 if window hidden             */
  198.     unsigned                overlapped    : 1;        /* 1 if window overlapped         */
  199.     unsigned                csr_adv            : 1;                /* advance the cursor?                        */
  200.     unsigned                csr_on            : 1;                /* does flashing cursor track?        */
  201.     unsigned                 inside      : 1;                /* 1 if bordered and inside              */
  202.     unsigned                 mask_on     : 1;                /* 1 if window mask is active            */
  203.     unsigned                 cr_lf       : 1;                /* 1 if cr translated to cr/lf        */
  204.     unsigned                full_size        : 1;        /* 1 if window full sized         */
  205.     unsigned                popup                :    1;                /* 1 if window is popup                        */
  206.     unsigned                 scroll      : 1;                /* 1 if window auto-scrolls                */
  207.     unsigned                bs_clear        : 1;                /* 1 if backspace is destructive    */
  208.     unsigned                eol_wrap        : 1;                /* 1 if cursor wraps at end of ln */
  209.     unsigned                unused            : 3;
  210.  
  211.     void            *usr_ptr;                 /* user expansion pointer         */
  212.     uchar           usr_exp[4];                            /* user expansion space                        */
  213.                                           /* DO NOT USE BELOW VARIABLES     */
  214.     void            *sys_ptr;               /* system expansion pointer       */
  215.     uchar           sys_exp[4];                          /* system expansion space                    */
  216. } WINDOW;
  217.  
  218. /*---------------------------- menu structure ------------------------------*/
  219. typedef struct menu_struct
  220. {
  221.     WINDOW        *wnp;                                                            /* the window for output            */
  222.     uchar            direction;                                                /* menu direction, up/dn            */
  223.     uchar            num_entries;                                            /* number of entries in menu    */
  224.     uchar            max_entries;                                            /* maximum number of entries    */
  225.     uchar            csr_att;                                                    /* the cursor attribute                */
  226.     uchar            first_att;                                                /* the first letter attribute    */
  227.     int                csr_pos;                                                    /* current cursor position        */
  228.     char            first_pos[M_MAX_ENTRIES];
  229.     char            id[M_MAX_ENTRIES];                                /* negative id value                    */
  230.     uchar            x[M_MAX_ENTRIES];                                    /* x location for each entry    */
  231.     char            *entry[M_MAX_ENTRIES];                        /* array of char pointers            */
  232. } MENU;
  233.  
  234. typedef struct printer
  235. {
  236.     int   active;                                            /* set to 1 if printer init'd/active    */
  237.     int   halt;                       /* set to 1 to temporarily stop printer */
  238.     int   prt_dev;                    /* file handle for printer device                */
  239.     char  device[81];                 /* name of printer device               */
  240.     int   prt_buff[2];                                /* file handles for printer buffer            */
  241.     char  buffer[81];                 /* name of printer buffer               */
  242.     int   cr_cnt;                     /* number of carriage returns to send   */
  243.     int   lf_cnt;                         /* number of line feeds to send         */
  244.     int   block_mode;                                    /* allows faster output on block devices*/
  245.  
  246.     long  max_que_size;                                /* maximum size of print que                      */
  247.     long  init_que_size;                            /* initial size of print que                        */
  248.     long  curr_que_size;                            /* current size of print que                        */
  249.     long  read;                                                /* print que read  index                */
  250.     long  write;                      /* print que write index                */
  251.     long  cnt;                           /* print que cnt (number of bytes in q) */
  252.  
  253.     uchar *que;                              /* pointer to print que data            */
  254.     uchar *xlat;                      /* pointer to translation table                    */
  255.     int   xlat_flag;                  /* translation flag                                            */
  256. } PRINT;
  257.  
  258. /*----------------------------- generic macros -----------------------------*/
  259. #define lower(x, y)          (((x) < (y)) ? (x) : (y))
  260. #define upper(x, y)          (((x) > (y)) ? (x) : (y))
  261. #define lobyte(c)              (uchar) ((c) & 0x00ff)
  262. #define hibyte(c)              (uchar) ((c) >> 8)
  263. #define range(l,b,h)    ( (((b) >= (l)) && ((b) <= (h))) ? 1:0 )
  264. #define swap( a,b,c)      ( (c) = (a), (a) = (b), (b) = (c) )
  265.  
  266. #ifndef min
  267. #define min(x, y)              (((x) < (y)) ? (x) : (y))
  268. #define max(x, y)              (((x) > (y)) ? (x) : (y))
  269. #endif
  270.  
  271. /*----------------------------- window macros ------------------------------*/
  272. #define wn_att(a,wnp)             ( (wnp)->att = (a) )
  273. #define wn_color(f,b,wnp)          ( (wnp)->att = ((b) << 4) | (f) )
  274. #define wn_bdratt(a,wnp)          ( (wnp)->bdr_att = (a) )
  275. #define wn_bdr_color(f,b,wnp)    ( (wnp)->bdr_att = ((b) << 4) | (f) )
  276. #define mv_cs(c,r,wnp)                ( (wnp)->csr_x = (c), (wnp)->csr_y = (r) )
  277. #define wn_rqty(wnp)                    ( (wnp)->inside ? ((wnp)->rows - 2) : (wnp)->rows )
  278. #define wn_sqty(wnp)                    ( (wnp)->reg_e - (wnp)->reg_s )
  279. #define wn_cqty(wnp)                    ( (wnp)->inside ? ((wnp)->cols - 2) : (wnp)->cols )
  280. #define wn_name(n, wnp)                ( (wnp)->name = (n) )
  281. #define wn_name_loc(l, wnp)        ( (wnp)->name_loc = (l) )
  282. #define wn_save( wnp )                ( wn_io( IN, SAVE, (wnp)) )
  283. #define wn_restore( wnp )            ( wn_io(OUT, SAVE, (wnp)) )
  284. #define wn_rfsh( wnp )                ( wn_io(OUT, BUFF, (wnp)) )
  285. #define wn_read( wnp )                ( wn_io( IN, BUFF, (wnp)) )
  286. #define cls()                                    ( setmem(Screen, V_cols * V_rows * 2, 0) )
  287. #define push(x)                              ( Stack[Stack_ptr++] = (x) )
  288. #define pop(x)                               ( x = Stack[--Stack_ptr] )
  289.  
  290. #include "uw_proto.h"
  291. /**** END OF FILE ****/